<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of login
 *
 * @author Queue
 */
class login extends CI_Controller {
    /**
     * Login Username
     * @var string
     */
    private $username;
    /**
     * Login Password
     * @var string
     */
    private $password;
    public function __construct() {
        parent::__construct();
        $this->output->set_content_type('text/html; charset=utf-8');
        $this->load->library('myeng');
    }
    /**
     * Page landing for anonymous user
     * @return bool
     */
    public function index() {
        // Set variable
        $var = array();
        // Set the title
        $this->template->title = 'Please Login Before Use';
        $this->template->content->view('login', $var);
        $this->template->publish();
        return true;
    }
    /**
     * Get login for process login
     * @return bool
     */
    public function process() {
        $this->username = trim($this->input->post('username'));
        $this->password = trim($this->input->post('password'));
        if(strlen($this->username) > 0 && strlen($this->password) > 0) {
                $id = $this->myeng->checklogin($this->username, $this->password);
                print_r($id);
                /*
                if(count($id)>0) {
                    $_SESSION["user"] = $id['ID'];
                    $_SESSION["userinfo"] = $id['NAME']." ".$id['SURNAME'];
                }*/
        }else{
            redirect('login', 'refresh');
        }
        return true;
    }
}

?>
